package com.gitee.wsl.markdown.html.tag
/*

import android.text.TextUtils
import com.gitee.wsl.markdown.html.tag.AbstractRectSizeTagHandler
import com.gitee.wsl.markdown.html.tag.SizeParser
import com.gitee.wsl.markdown.html.tag.SizeParserImpl
import io.noties.markwon.base.MarkwonConfiguration
import io.noties.markwon.base.RenderProps
import io.noties.markwon.base.html.CssInlineStyleParser
import io.noties.markwon.base.html.HtmlTag
import io.noties.markwon.base.html.iframe.Iframe
import io.noties.markwon.base.html.iframe.IframeProps
import io.noties.markwon.base.image.ImageProps

class IframeHandler( imageSizeParser : SizeParser = SizeParserImpl(CssInlineStyleParser.create()))  : AbstractRectSizeTagHandler(imageSizeParser) {

    override fun supportedTags(): List<String> {
        return listOf("iframe")
    }

    override fun getSpans(
        configuration: MarkwonConfiguration,
        renderProps: RenderProps,
        tag: HtmlTag
    ): Any? {
        val attributes = tag.attributes()
        val src = attributes["src"]
        if (TextUtils.isEmpty(src)) {
            return null
        }

        var poster = attributes["poster"]

        val spanFactory = configuration.spansFactory()[Iframe::class.java] ?: return null

        poster = if (TextUtils.isEmpty(poster))
            "drawable://placeholder_image_article_day"
        else
            configuration.imageDestinationProcessor().process(poster!!)


        // todo: replacement text is link... as we are not at block level
        // and cannot inspect the parent of this node... (img and a are both inlines)
        //
        // but we can look and see if we are inside a LinkSpan (will have to extend TagHandler
        // to obtain an instance SpannableBuilder for inspection)
        ImageProps.DESTINATION[renderProps] = poster

        sizeParser(configuration, renderProps, tag)

        ImageProps.REPLACEMENT_TEXT_IS_LINK[renderProps] = false
        IframeProps.IFRAME_DESTINATION[renderProps] = configuration.imageDestinationProcessor().process(src!!)

        return spanFactory.getSpans(configuration, renderProps)
    }
}*/
